// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        hotdog:require('hotdog'),
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.node.on(cc.Node.EventType.TOUCH_START,this.ontouched,this);
        cc.log('start');
        this.manager = cc.director.getPhysicsManager();
        this.init();
    },
    ontouched:function(event){
        cc.log(event.getLocationX()+','+event.getLocationY()+this.hotdog.node.rotation);
        this.hotdog.turn(event.getLocationX(),event.getLocationY());
        var nhotdog = cc.instantiate(this.hotdog);
        nhotdog.parent = this.node;
        nhotdog.init();
        this.node.off(cc.Node.EventType.TOUCH_START,this.ontouched,this);
    },
    init(){
        this.manager.enabled = true;
        this.hotdog.init(this);
    },
    onBallContactWall(ballNode, brickNode) {
    },
    start () {

    },

    // update (dt) {},
});
